import request from "@/utils/request"

export function getOrgAndDescendant(param) {
  return request({
    url: `/basic/hisMedicalStaff/list/getOrgAndDescendant`,
    method: "get",
    params: param
  })
}

export function getMedicalStaffByPage(param) {
  return request({
    url: `/basic/hisMedicalStaff/page`,
    method: "get",
    params: param
  })
}

export function addMedicalStaff(data, config) {
  return request({
    url: `/basic/hisMedicalStaff`,
    method: "post",
    config: config,
    data: data
  })
}

export function updateMedicalStaff(data, config) {
  return request({
    url: `/basic/hisMedicalStaff`,
    method: "put",
    config: config,
    data: data
  })
}

export function deleteMedicalStaff(hisMedicalStaffId) {
  return request({
    url: `/basic/hisMedicalStaff/${hisMedicalStaffId}`,
    method: "delete"
  })
}

export function getStaffDutyByStaffId(hisMedicalStaffId) {
  return request({
    url: `/basic/hisMedicalStaffDuty/${hisMedicalStaffId}`,
    method: "get"
  })
}

export function addStaffDutyBatch(param) {
  return request({
    url: `/basic/hisMedicalStaffDuty`,
    method: "post",
    params: param
  })
}

export function getOrgAndDeptLazyLoad(sysOrganizationId) {
  return request({
    url: `/upms/organization/getOrgAndDeptLazyLoad/${sysOrganizationId}`,
    method: "get"
  })
}

// 查询机构下面的科室
export function getDeptsBySysOrgId(data) {
  return request({
    url: `/basic/hisDept/list/dept?sysOrganizationId=${data.sysOrganizationId}&hisDeptId=${data.hisDeptId}`,
    method: "get"
  })
}

export function saveStaffRegAndDeptBatch(data) {
  return request({
    url: `/basic/hisMedicalStaffReg`,
    method: "post",
    data
  })
}

export function getMedicalStaffReg(param) {
  return request({
    url: `/basic/hisMedicalStaffReg/list`,
    method: "get",
    params: param
  })
}

export function getCurrentSysOrg(sysOrganizationId) {
  return request({
    url: `/upms/organization/getLazyOrganization?sysOrganizationId=${sysOrganizationId}`,
    method: "get"
  })
}

export function getChildDeptByHisDeptId(data) {
  return request({
    url: `/basic/hisDept/list/getDeptByHisDeptId`,
    method: "post",
    data
  })
}

export function getLeafOrganization(sysOrganizationId) {
  return request({
    url: `/upms/organization/getLeafOrganization/${sysOrganizationId}`,
    method: "get"
  })
}

export function getStaffOfNotLeafOrg(param) {
  return request({
    url: `/basic/hisMedicalStaff/getStaffOfNotLeafOrg`,
    method: "get",
    params: param
  })
}

export function getStaffByStaffCode(staffCode) {
  return request({
    url: `/basic/hisMedicalStaff/getStaffByStaffCode/${staffCode}`,
    method: "get"
  })
}

export function getDutyAll() {
  return request({
    url: `/basic/hisDutyInfo/list`,
    method: "get"
  })
}

export function checkUserNameExist(userName) {
  return request({
    url: `/basic/hisMedicalStaff/checkUserNameExist/${userName}`,
    method: "get"
  })
}

export function getAdminiDeptsBySysOrgId(data) {
  return request({
    url: `/basic/hisDept/getAdminiDeptsBySysOrgId`,
    method: "post",
    data
  })
}

export function checkExistStaffByTelephone(param) {
  return request({
    url: `/basic/hisMedicalStaff/checkExistStaffByTelephone`,
    method: "get",
    params: param
  })
}

export function getDrugType(data) {
  return request({
    url: `/his/drugStorage/getDrugType/${data}`,
    method: "get"
  })
}

//查询医生职称
export function getDoctorTitle(query) {
  return request({
    url: "/his/register/getDoctorTitle",
    method: "get",
    params: query
  })
}

// 角色权限
export function getAllRoleIdAndName() {
  return request({
    url: `/upms/sysRole/getAllRoleIdAndName`,
    method: "get"
  })
}

// ---------
/**
 * 科室类别：用作条件查询科室的下级科室主键的最大值
 * @type {{administrationDept: Array, sittingDept: Array}}
 */
export const departmentType = {
  administrationDept: [1, 2, 3, 4, 5], // 3.业务科室
  sittingDept: [1, 2, 3, 4, 5] // 坐诊科室：3.业务科室
}

/**
 * 科室类别：作为条件动态查询科室
 * @type {{administrationDept: number[], sittingDept: number[]}}
 */
export const deptCategory = {
  administrationDept: [1, 2, 3, 4, 5], // 3.业务科室
  sittingDept: [1, 2, 3, 4, 5] // 坐诊科室：3.业务科室
}
